use crate::models::*;
use mysql::{self,prelude::*};
use mysql::*;
pub async fn get_all_products(db: &Pool) -> Vec<Product>{
    let mut conn = db.get_conn().unwrap();
    let rows = conn
    .query_map("select * from tb_products",
    |(id, product_no, product_type, product_suit_season, product_count, product_name,
         product_color, product_size, product_price, product_note, reserve1, reserve2)|
          Product{
        id: id,
        product_no : product_no,
        product_type : product_type,
        product_suit_season : product_suit_season,
        product_amount : product_count,
        product_name : product_name,
        product_color :  product_color,
        product_size :  product_size,
        product_price :  product_price,
        product_note :  product_note,
        reserve1 : reserve1,
        reserve2 :  reserve2 ,
    }).expect("Query failed");
    rows
}